package com.roin.learn.activiti.service;

import com.alibaba.fastjson.JSONObject;
import com.roin.learn.activiti.entity.Page;
import org.activiti.bpmn.model.FlowElement;
import org.activiti.engine.history.HistoricActivityInstance;
import org.activiti.engine.history.HistoricProcessInstance;
import org.activiti.engine.repository.Deployment;
import org.activiti.engine.repository.Model;
import org.activiti.engine.repository.ProcessDefinition;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;

import java.io.IOException;
import java.io.InputStream;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.zip.ZipInputStream;

public interface ProcessService {
    public List<Model> queryModel(String modelId);
    public void deleteModel(String modelId);

    public Deployment deployClasspathResource(String bpmnPath, String name);

    public Deployment deployInputStream(InputStream bpmnPath, InputStream pngPath, String name);

    public Deployment deployZipInputStream(ZipInputStream zipInputStream,String name);

    public Deployment deployString(String bpmnXml, String name);

    public void deleteProcessDefinition(String id, boolean flag);

    public ProcessInstance startProessInstance(String processDefinitionKey, String businessKey, Map<String, Object> jsnVariables) throws Exception;

    public Page<Task> queryAssigneeTask(String assignee, int pageNum, int pageSize) throws Exception;

    public int queryAssigneeTaskCount(String assignee) throws Exception;

    public List<Task> queryTaskProcessInstanceId(String processInstanceId, Map<String, Object> jsnVariables) throws Exception;

    public List<Task> queryCandidateUserTask(String candidateUser) throws Exception;

    public List<Task> queryCandidateGroupTask(List<String> candidateGroup) throws Exception;

    public void completeTask(String taskId, Map<String, Object> variables) throws Exception;

    public void completeTaskProcessInstanceId(String processInstanceId, String assignee, Map<String, Object> variables);

    public List<ProcessInstance> getProcessInstanceList(String processDefinitionKey);

    public ProcessInstance getProcessInstanceByBusinessKey(String businessKey) throws Exception;

    public ProcessInstance getProcessInstanceById(String processInstanceId) throws Exception;

    public Task getTaskByBusinessKey(String businessKey);

    public void takeTask(String taskId, String userId) throws Exception;

    public void delegatedTask(String taskId, String userId) throws Exception;

    public boolean isFinished(String processInstanceId);

    public void addGroupUser(String taskId, String userId);

    public void deleteGroupUser(String taskId, String userId);

    public List<ProcessDefinition> findProcessDefintion(String deploymentId, String processDefinitionId, String processDefinitionKey, String processDefinitionKeyLike, String ascOrDesc);

    public InputStream processTracking(String processDefinitionId, String executionId) throws Exception;

    public Collection<FlowElement> queryFlowElement(InputStream resouceStream);

    public void deleteProcessDefinitionByKey(String processDefinitionKey);

    public InputStream getDiagramByDeploymentId(String deploymentId) throws IOException;

    public List<Task> queryTaskList(String processDefinitionKey) throws Exception;

    public Task queryTaskById(String taskId);

    public Map<String, Object> getTaskVariables(String taskId) throws IOException;

    public HistoricProcessInstance findHistoryProcessInstanceByBusKey(String businessKey) throws Exception;

    Task queryActiviTask(String processInstanceId, String userId) throws Exception;

    List<HistoricActivityInstance> getHistoricActivityInstance(String processInstanceId, String assignee);

    Page<Task> queryCandidateUserTask(String candidateUser, int pageNum, int pageSize) throws Exception;
}
